用户工具

站点工具


语法:tcl语法速查

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
后一修订版
前一修订版
语法:tcl语法速查 [2025/08/28 17:17] – [6.4 产生递进的二进制数] user01语法:tcl语法速查 [2026/04/08 09:41] (当前版本) – [6.5 set_bits get_bits] user01
行 506: 行 506:
 </code> </code>
  
-==== - com_number set_bits get_bits ====+==== - set_bits get_bits ====
  
 <code tcl> <code tcl>
行 530: 行 530:
         default { set ret 0000 }         default { set ret 0000 }
     }     }
-    # set ret [format "%04b" "0x$h"] 
     return $ret     return $ret
 } }
行 539: 行 538:
     for {set i 0} {$i<$len} {incr i} {     for {set i 0} {$i<$len} {incr i} {
         set tmp [string range $hex_value $i $i]         set tmp [string range $hex_value $i $i]
-        #set bins [string cat $bins [format "%04b" "0x$tmp"]] 
         set tmp [h2b $tmp]         set tmp [h2b $tmp]
         set bins "$bins$tmp"         set bins "$bins$tmp"
行 558: 行 556:
     for {set i 0} {$i<[expr $len/4]} {incr i} {     for {set i 0} {$i<[expr $len/4]} {incr i} {
         set tmp [string range $bins [expr 0+$i*4] [expr 3+$i*4]]         set tmp [string range $bins [expr 0+$i*4] [expr 3+$i*4]]
-        #set hexs [string cat $hexs [format "%0x" "0b$tmp"]] 
         set tmp [format "%0x" "0b$tmp"]         set tmp [format "%0x" "0b$tmp"]
         set hexs "$hexs$tmp"         set hexs "$hexs$tmp"
行 989: 行 986:
 </code> </code>
  
 +字符串方式直接创建dict
 +<code tcl>
 +set mydict {
 +    a {
 +        num1 {1}
 +        num2 {2}
 +    }
 +    b {
 +        num3 {3}
 +        num4 {4}
 +    }
 +}
 +set a    [dict get $mydict a]
 +set num1 [dict get $a num1]
 +set num2 [dict get $a num2]
 +set b    [dict get $mydict b]
 +set num3 [dict get $b num3]
 +set num4 [dict get $b num4]
 +
 +</code>
  
 ==== - dict unset 删除某个key ==== ==== - dict unset 删除某个key ====
语法/tcl语法速查.1756372638.txt.gz · 最后更改: 2025/08/28 17:17 由 user01

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki