将十六进制字符串转换为十六进制值

时间:2017-08-14 10:22:14

标签: python-3.x terminal ascii

如何在我从CREATE TABLE #temp (value INT, active BIT, model NVARCHAR(10)); INSERT INTO #temp( value, active, model ) VALUES (1, 1, ''), (2, 0, ''), (1, 0, 'Powys'); CREATE TABLE #destination (value INT, active BIT, model NVARCHAR(10)); INSERT INTO #destination( value, active, model ) SELECT t.value, t.active, t.model FROM #temp AS t; SELECT * FROM #destination; DROP TABLE #temp; DROP TABLE #destination;

读取字符串u"\u2660"的终端打印♠
data.txt

data = "./data.txt" with open(data, 'r') as source: for info in source: print(info) 是我在终端中获得的

1 个答案:

答案 0 :(得分:0)

字符串u"\u2660"只是txt文件中的纯文本。它需要由python解释器解释为成为表示unicode字符的字符串。你可以使用eval来做到这一点。

>>> a=r'u"\u2660"'
>>> print(a)
u"\u2660"
>>> b = eval(a)
>>> print(b)
♠