2017年4月14日 星期五

[DOS] ConEmu,多分頁的DOS模式軟體

 

1.         Setting

2.         Startup

3.         Command line

4.         設定cmd.exe

 

 

 

 

l   New Console tab

 

 

 

 

REF

https://conemu.github.io/

 

________________________________________ 3S CONFIDENTIALITY NOTICE: This message and all attachments may contain legally privileged and confidential information. Any unauthorized review, use or distribution by anyone other than the intended recipient is strictly prohibited. If you are not the intended recipient, please contact the sender immediately by replying to the message and delete all copies. Thank you.

2017年4月13日 星期四

[python] 'cp950' , illegal , UnicodeEncodeError

Traceback (most recent call last):

  File "D:\3S_PC\python\3S_AUTO\FileStudy.py", line 521, in <module>

    parseXML(xmlPath)

  File "D:\3S_PC\python\3S_AUTO\FileStudy.py", line 496, in parseXML

    print ('{}, Unexpected error:{}'.format(testName, sys.exc_info()))

UnicodeEncodeError: 'cp950' codec can't encode character '\xf1' in position 215: illegal multibyte sequence

 

 

原因:

使用 windows cmd print時會轉碼為cp950,但python使用unicode

 

 

 

SOL

    try:

        for item in sortlistFileInfo3:       

            if (len(item) == 4):

                print('{:<10d},{:<10d},{:<10d},{:45s},{}'.format(nIndex,

                    item[0],

                    item[1],

                    item[2].encode("utf8").decode("cp950", "ignore"),

                    item[3].encode("utf8").decode("cp950", "ignore")))

            else:

                print('!!!{:<10d},{}'.format(nIndex, item))       

            nIndex += 1   

    except:

        print ('Show listFile3, Unexpected error:{}'.format(sys.exc_info()))

 

 

________________________________________ 3S CONFIDENTIALITY NOTICE: This message and all attachments may contain legally privileged and confidential information. Any unauthorized review, use or distribution by anyone other than the intended recipient is strictly prohibited. If you are not the intended recipient, please contact the sender immediately by replying to the message and delete all copies. Thank you.

2017年4月6日 星期四

[python] format

它有着丰富的的"格式限定符"(语法是{}中带:号),比如:

填充与对齐
填充常跟对齐一起使用
^
<>分别是居中、左对齐、右对齐,后面带宽度
:
号后面带填充的字符,只能是一个字符,不指定的话默认是用空格填充
比如

In [15]: '{:>8}'.format('189')
Out[15]: '     189'
In [16]: '{:0>8}'.format('189')
Out[16]: '00000189'
In [17]: '{:a>8}'.format('189')
Out[17]: 'aaaaa189'

精度与类型f
精度常跟类型f一起使用

In [44]: '{:.2f}'.format(321.33345)
Out[44]: '321.33'

其中.2表示长度为2的精度,f表示float类型。

其他类型
主要就是进制了,bdox分别是二进制、十进制、八进制、十六进制。

In [54]: '{:b}'.format(17)
Out[54]: '10001'
In [55]: '{:d}'.format(17)
Out[55]: '17'
In [56]: '{:o}'.format(17)
Out[56]: '21'
In [57]: '{:x}'.format(17)
Out[57]: '11'

用,号还能用来做金额的千位分隔符。

In [47]: '{:,}'.format(1234567890)
Out[47]: '1,234,567,890'

 

 

Ref:

http://blog.csdn.net/handsomekang/article/details/9183303

 

________________________________________ 3S CONFIDENTIALITY NOTICE: This message and all attachments may contain legally privileged and confidential information. Any unauthorized review, use or distribution by anyone other than the intended recipient is strictly prohibited. If you are not the intended recipient, please contact the sender immediately by replying to the message and delete all copies. Thank you.