`;
switch(displayFormat) {
case 'text-only':
html += `
`;
break;
case 'small-with-description':
html += `
${imgSmallUrl ? `
` : ''}
${description}
`;
break;
case 'banner-only':
html += `
`;
break;
case 'big-only':
html += `
`;
break;
case 'big-with-description':
html += `
`;
html += `
`;
break;
case 'big-with-title-description-button':
html += `
`;
html += `
`;
html += `
`;
break;
default:
html += `
`;
}
html += `
`
return html;
}
// Load campaign from emitter
var xhr = new XMLHttpRequest();
xhr.open('GET', '/pro/emitter', true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
try {
var campaign = JSON.parse(xhr.responseText);
if (campaign && campaign.id) {
var html = renderCampaign(campaign);
var container = document.getElementById('pro-campaign-container');
if (html) {
container.innerHTML = html;
bindCampaignLinks(container);
} else {
container.style.display = 'none';
}
} else {
document.getElementById('pro-campaign-container').style.display = 'none';
}
} catch (e) {
document.getElementById('pro-campaign-container').style.display = 'none';
console.log('Error parsing campaign data: ' + e.message);
}
} else {
document.getElementById('pro-campaign-container').style.display = 'none';
console.log('Error loading campaign: HTTP ' + xhr.status);
}
}
};
xhr.send();
});
This topic created in 4516 days ago, the information mentioned may be changed or developed.
因为要在cmd输出中文,所以我用unicode输出
程序如下
#coding=utf-8
print u'中文测试'
raw_input()
在pycharm和cmd都能正常显示中文,但用sublime_text调试则出现
Traceback (most recent call last):
File "S:\test.py", line 3, in <module>
print u'中文测试'
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
求大神支招~
5 replies • 1970-01-01 08:00:00 +08:00
 |
|
1
tan9le Feb 16, 2014
#coding=utf-8 -> # -*- coding:utf-8 -*- 试下
|
 |
|
3
binux Feb 16, 2014
print u'中文测试'.encode("utf8")
或者
sys.setdefaultencoding("utf8")
|
 |
|
4
pc10201 Feb 16, 2014
@ binux 以上方法都不行,好像是sublime_text输出的只能是utf-8编码,不能更改,算了,还是用pycharm吧
|