utf-8
中的python文件,需要标题
# -*- coding: utf-8 -*-
*.robot
个文件位于utf-8
在具有非ascii符号的机器人文件中执行此关键字给出:
"%s" % msg
:没有错误,则日志文件会显示俄语消息,通常会显示。"{}".format(msg)
或"{!s}".format(msg)
:我收到错误UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-10: ordinal not in range(128)
正如您所看到的,我只将旧的python格式更改为新方式。但是如何解决这个问题用非新的方式解决非asc显示错误,而不是使用旧式格式化?
答案 0 :(得分:0)
尝试使用Str.decode(encoding='UTF-8',errors='strict')方法。请参阅Python doc。
示例:
<div class="wrapper">
<header class="title-block">
<h1>Palindrome Checker</h1>
<h3>A <span>palindrome</span> is a word, phrase, or sentence that reads the same backward and forward.</h3>
</header>
<form>
<label for="input"></label>
<input id="input" type="text" placeholder="Enter a word, phrase, or sentence..." />
<button onclick="palindrome(event)">Check Palindrome</button>
</form>
<div id="results"></div>
</div>