在HTML中遇到字符串问题 [英] Having problems with strings in HTML

查看:51
本文介绍了在HTML中遇到字符串问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我收到一个非常奇怪的错误:

ValueError:索引237处不支持的格式字符''t''(0x74) />

这是'我的代码:

HI_LITE_FILE_NAME =''/ var / tmp / out.txt''


打印''''''

< a

href =" http://bbc.botany.utoronto.ca/ntools/cgi-bin/ntools_treeview_word .cgi?input =& max = 2& values_off = n o& remove_bracket = no& show_line_nr = yes& show_link_out = yes& decimal_places = 10& show_classification = yes& db = arabidopsis& selection = any%20term& mode =& mode_nos =& y ellow_blue = yes& local_file_name =%(OUT_FILE_NAME)s& s how_instructions = no& expt_link = NASCArrays& max_adjus t = 2& view_size = large& highlight =%(HI_LITE_FILE_NAME)s"> GraphicalOutput< / a>

''''''%{''OUT_FILE_NAME'':OUT_FILE_NAME,''HI_LITE_FILE_NAME'':

HI_LITE_FILE_NAME}


我不知道是否这与HTML'的%字符有关。


KT

Hi,

I get a very odd error:
ValueError: unsupported format character ''t'' (0x74) at index 237

Here''s my code:
HI_LITE_FILE_NAME = ''/var/tmp/out.txt''

print ''''''
<a
href="http://bbc.botany.utoronto.ca/ntools/cgi-bin/ntools_treeview_word.cgi?input=&max=2&values_off=n o&remove_bracket=no&show_line_nr=yes&show_link_out =yes&decimal_places=10&show_classification=yes&db= arabidopsis&selection=any%20term&mode=&mode_nos=&y ellow_blue=yes&local_file_name=%(OUT_FILE_NAME)s&s how_instructions=no&expt_link=NASCArrays&max_adjus t=2&view_size=large&highlight=%(HI_LITE_FILE_NAME) s">GraphicalOutput</a>
'''''' % {''OUT_FILE_NAME'': OUT_FILE_NAME, ''HI_LITE_FILE_NAME'':
HI_LITE_FILE_NAME}

I wonder if this has something to do with HTML''s % character.

KT

推荐答案

Kiana Toufighi写道:
Kiana Toufighi wrote:


我得到一个非常奇怪的错误:
ValueError:索引237处不支持的格式字符''t''(0x74)

这是我的代码:
HI_LITE_FILE_NAME =''/ var / tmp / out.txt''

打印''''''br />< a
href =" http://bbc.botany.utoronto.ca/ntools/cgi-bin/ntools_treeview_word.cgi?input =& max = 2& values_off = n o& remove_bracket = no& show_line_nr = yes& show_link_out = yes& decimal_places = 10& show_classification = yes& db = arabidopsis& selection = any%20term& mode =& mode_nos =& y ellow_blue = yes& local_file_name =%(OUT_FILE_NAME)s& s how_instructions = no& expt_link = NASCArrays& max_adjus t = 2& view_size = large& highlight =%(HI_LITE_FILE_NAME)s"> GraphicalOutput< / a>

'''''''%{''OUT_FILE_NAME'':OUT_FILE_NAME,''HI_LITE_FILE_NAME'':
HI_LITE_FILE_NAME}

我想知道这是否有事情要做使用HTML'%字符。

KT
Hi,

I get a very odd error:
ValueError: unsupported format character ''t'' (0x74) at index 237

Here''s my code:
HI_LITE_FILE_NAME = ''/var/tmp/out.txt''

print ''''''
<a
href="http://bbc.botany.utoronto.ca/ntools/cgi-bin/ntools_treeview_word.cgi?input=&max=2&values_off=n o&remove_bracket=no&show_line_nr=yes&show_link_out =yes&decimal_places=10&show_classification=yes&db= arabidopsis&selection=any%20term&mode=&mode_nos=&y ellow_blue=yes&local_file_name=%(OUT_FILE_NAME)s&s how_instructions=no&expt_link=NASCArrays&max_adjus t=2&view_size=large&highlight=%(HI_LITE_FILE_NAME) s">GraphicalOutput</a>

'''''' % {''OUT_FILE_NAME'': OUT_FILE_NAME, ''HI_LITE_FILE_NAME'':
HI_LITE_FILE_NAME}

I wonder if this has something to do with HTML''s % character.

KT




是的。看看urllib.quote和unquote。这些可能会有所帮助。


James


-

James Stroud

加州大学洛杉矶分校-DOE基因组学和蛋白质组学研究所

方框951570

洛杉矶,加利福尼亚州90095

http://www.jamesstroud.com/


On 27/06/2006 7:51 AM,Kiana Toufighi写道:
On 27/06/2006 7:51 AM, Kiana Toufighi wrote:


我得到一个非常奇怪的错误:
ValueError:不支持的格式字符''t''(0x74 )索引237

这是我的代码:
HI_LITE_FILE_NAME =''/ var / tmp / out.txt''

打印'''' ''
< a
href =" http://bbc.botany.utoronto.ca/ntools/cgi-bin/ntools_treeview_word.cgi?input =& max = 2& values_off = n o& remove_bracket = no& show_line_nr = yes& show_link_out = yes& decimal_places = 10& show_classification = yes& db = arabidopsis& selection = any%20term& mode =& mode_n os =& y ellow_blue = yes& local_file_name =%(OUT_FILE_NAME)s& s how_instructions = no& expt_link = NASCArrays& max_adjus t = 2& view_size = large& highlight =%(HI_LITE_FILE_NAME)s"> GraphicalOutput< / a>

''''''%{''OUT_FILE_NAME'':OUT_FILE_NAME,''HI_LITE_FILE_NAME'':
HI_LITE_FILE_NAME}


该代码产生:

NameError:名称''OUT_FILE_NAME''未定义

当补救时,*然后*一个得到ValueError。

*请*,在提问时,准确发布您运行的代码,

并包含完整的追溯,而不仅仅是最后一行。

我想知道这是否有与HTML'的%字符有关。
Hi,

I get a very odd error:
ValueError: unsupported format character ''t'' (0x74) at index 237

Here''s my code:
HI_LITE_FILE_NAME = ''/var/tmp/out.txt''

print ''''''
<a
href="http://bbc.botany.utoronto.ca/ntools/cgi-bin/ntools_treeview_word.cgi?input=&max=2&values_off=n o&remove_bracket=no&show_line_nr=yes&show_link_out =yes&decimal_places=10&show_classification=yes&db= arabidopsis&selection=any%20term&mode=&mode_nos=&y ellow_blue=yes&local_file_name=%(OUT_FILE_NAME)s&s how_instructions=no&expt_link=NASCArrays&max_adjus t=2&view_size=large&highlight=%(HI_LITE_FILE_NAME) s">GraphicalOutput</a>

'''''' % {''OUT_FILE_NAME'': OUT_FILE_NAME, ''HI_LITE_FILE_NAME'':
HI_LITE_FILE_NAME}
That code produces:
NameError: name ''OUT_FILE_NAME'' is not defined
When that is remedied, *then* one gets the ValueError.
*Please*, when asking a question, post exactly the code that you ran,
and include the full traceback, not just the last line.

I wonder if this has something to do with HTML''s % character.




我不知道为什么你在想。错误消息告诉您确切地说

问题是什么以及

格式字符串中的确切位置(偏移237)。 。您的格式字符串(字符串%

运算符的第一个操作数)包含...& selection = any%20term ...而%20t看起来像

格式化操作,但(像它说的那样)''t''无效。


为了解决这个问题,你需要逃避任何实际上是
的URL加倍...& selection = any %% 20term ...


这与HTML无关... *任何*迷路''%''会让你感到悲伤:


|>> ''1%的%s很难理解''%''错误消息''

追溯(最近一次调用最后一次):

文件"< stdin> ;",第1行,在?

TypeError:需要int参数

你读过这个:
http://docs.python.org/lib/typesseq-strings.html



这可能会有所帮助。


干杯,

John



I''m not sure why you are wondering. The error message told you exactly
what the problem was and exactly where it was (offset 237) in your
format string. . Your format string (the first operand of the string %
operator) contains ...&selection=any%20term... and the %20t looks like a
formatting operation, but (like it said) ''t'' is not valid.

To overcome this you would need to escape any ''%'' that is actually part
of the URL by doubling it ...&selection=any%%20term...

This is nothing to do with HTML ... *any* stray ''%'' will give you grief:

|>> ''1% of %s are difficult to understand'' % ''error messages''
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: int argument required
Have you read this:
http://docs.python.org/lib/typesseq-strings.html
?
It may help.

Cheers,
John


2006年6月27日上午7:51,Kiana Toufighi写道:
On 27/06/2006 7:51 AM, Kiana Toufighi wrote:


我得到一个非常奇怪的错误:
ValueError:unsupported格式字符''t''(0x74)索引237

这是我的代码:
HI_LITE_FILE_NAME =''/ var / tmp / out.txt''

打印'''''
< a
href =" http://bbc.botany.utoronto.ca/ntools/cgi-bin/ntools_treeview_word.cgi?input = & max = 2& values_off = n o& remove_b racket = no& show_line_nr = yes& show_link_out = yes& decimal_places = 10& show_classification = yes& db = arabidopsis& selection = any%20term& mode =& mode_nos =& y ellow_blue = yes& local_file_name =%(OUT_FILE_NAME)s& ; s how_instructions = no& expt_link = NASCArrays& max_adjus t = 2& view_size = large& highlight =%(HI_LITE_FILE_NAME)s"> GraphicalOutput< / a>

'''''%{ ''OUT_FILE_NAME'':OUT_FILE_NAME,''HI_LITE_FILE_NAME'':
HI_LITE_FILE_NAME}


该代码生成:

NameError:name''OUT_FILE_NAME ''未定义

当补救时,*然后*一个得到ValueError。

*请问*,在提问时,准确发布您运行的代码,

并包括完整的追溯,而不仅仅是最后一行。

我想知道这是否与HTML'的%字符有关。
Hi,

I get a very odd error:
ValueError: unsupported format character ''t'' (0x74) at index 237

Here''s my code:
HI_LITE_FILE_NAME = ''/var/tmp/out.txt''

print ''''''
<a
href="http://bbc.botany.utoronto.ca/ntools/cgi-bin/ntools_treeview_word.cgi?input=&max=2&values_off=n o&remove_bracket=no&show_line_nr=yes&show_link_out =yes&decimal_places=10&show_classification=yes&db= arabidopsis&selection=any%20term&mode=&mode_nos=&y ellow_blue=yes&local_file_name=%(OUT_FILE_NAME)s&s how_instructions=no&expt_link=NASCArrays&max_adjus t=2&view_size=large&highlight=%(HI_LITE_FILE_NAME) s">GraphicalOutput</a>

'''''' % {''OUT_FILE_NAME'': OUT_FILE_NAME, ''HI_LITE_FILE_NAME'':
HI_LITE_FILE_NAME}
That code produces:
NameError: name ''OUT_FILE_NAME'' is not defined
When that is remedied, *then* one gets the ValueError.
*Please*, when asking a question, post exactly the code that you ran,
and include the full traceback, not just the last line.

I wonder if this has something to do with HTML''s % character.




我不知道你为什么这么做ondering。错误消息告诉您确切地说

问题是什么以及

格式字符串中的确切位置(偏移237)。 。您的格式字符串(字符串%

运算符的第一个操作数)包含...& selection = any%20term ...而%20t看起来像

格式化操作,但(像它说的那样)''t''无效。


为了解决这个问题,你需要逃避任何实际上是
的URL加倍...& selection = any %% 20term ...


这与HTML无关... *任何*迷路''%''会让你感到悲伤:


|>> ''1%的%s很难理解''%''错误消息''

追溯(最近一次调用最后一次):

文件"< stdin> ;",第1行,在?

TypeError:需要int参数

你读过这个:
http://docs.python.org/lib/typesseq-strings.html



这可能会有所帮助。


干杯,

John



I''m not sure why you are wondering. The error message told you exactly
what the problem was and exactly where it was (offset 237) in your
format string. . Your format string (the first operand of the string %
operator) contains ...&selection=any%20term... and the %20t looks like a
formatting operation, but (like it said) ''t'' is not valid.

To overcome this you would need to escape any ''%'' that is actually part
of the URL by doubling it ...&selection=any%%20term...

This is nothing to do with HTML ... *any* stray ''%'' will give you grief:

|>> ''1% of %s are difficult to understand'' % ''error messages''
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: int argument required
Have you read this:
http://docs.python.org/lib/typesseq-strings.html
?
It may help.

Cheers,
John


这篇关于在HTML中遇到字符串问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆