我想打印一些unicode字符,但u'\u1000'
打印到u'\u1099'
。这不起作用:
for i in range(1000,1100):
s=unicode('u'+str(i))
print i,s
答案 0 :(得分:11)
答案 1 :(得分:11)
答案 2 :(得分:5)
尝试以下方法:
for i in range(1000, 1100):
print i, unichr(i)
答案 3 :(得分:4)
unichr
是您正在寻找的函数 - 它需要一个数字并返回该点的Unicode字符。
for i in range(1000, 1100):
print i, unichr(i)
答案 4 :(得分:0)
如果要打印与任意unicode范围相对应的字符,则可以使用以下命令(python 3)
unicode_range = ('4E00', '9FFF') # (CJK Unified Ideographs)
characters = []
for unicode_character in range(int(unicode_range[0], 16), int(unicode_range[1], 16)):
characters.append(chr(unicode_character))
答案 5 :(得分:0)
一个人可能会喜欢这个 php-cli 版本:
它使用html实体和UTF8解码。
XTERM和其他终端的最新版本非常支持Unicode字符:)
private List<ItemObject> returnParsedJsonObject(String result) {
List<ItemObject> jsonObject = new ArrayList<ItemObject>();
JSONObject resultObject;
JSONArray jsonArray = null;
ItemObject newItemObject; //interior object holder
try {
resultObject = new JSONObject(result);
System.out.println("Preparsed JSON object " +
resultObject.toString());
// set up json Array to be parsed
jsonArray = resultObject.optJSONArray("Bluesy_Music");
} catch (JSONException e) {
e.printStackTrace();
}
int counter = 0;
String oneObjectsItem= new String();
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jsonChildNode = null;
try {
jsonChildNode = jsonArray.getJSONObject(i);
//get all data from stream
String sold = jsonChildNode.getString("SOLD");
String title = jsonChildNode.getString("TITLE");
String artist = jsonChildNode.getString("ARTIST");
String country = jsonChildNode.getString("COUNTRY");
String company = jsonChildNode.getString("COMPANY");
float price = jsonChildNode.getInt("PRICE");
String year = jsonChildNode.getString("YEAR");
newItemObject = new ItemObject(sold, title, artist, country, company, price, year);
jsonObject.add(newItemObject);
//show all title
counter++;
//getting the most price of the most expensive CD
pricelist.add(price);
Collections.sort( pricelist, Collections.reverseOrder());
//getting the title of the most expensive CD
expensivecd = (float) pricelist.get(0);
if(price==expensivecd){
expensivetitle = title;
}
} catch (JSONException e) {
e.printStackTrace();
}
}
//data title counter
data.append(counter);
return jsonObject;
}