Latest posts on hex topichttp://python.su/forum/topic/3337/2008-12-07T12:19:04+02:00Общий :: Python для новичков :: hex
2008-12-07T12:19:04+02:00slav0nic21209у hex() в параметре только число может быть, надо примерно так:<br/><div class="code"><pre>hex_data = ' '.join([(hex(ord(h))) for h in data])</pre></div>
Общий :: Python для новичков :: hex
2008-12-06T19:03:20+02:00f0221160<strong>lorien</strong><br/><div class="code"><pre> h=hex(ptext)<br/>TypeError: hex() argument can't be converted to hex</pre></div><strong>poltergeist</strong><br/>спасибо.
Общий :: Python для новичков :: hex
2008-12-06T18:54:23+02:00poltergeist21158print ‘hex: ’ + ptext.encode('hex')
Общий :: Python для новичков :: hex
2008-12-06T18:39:22+02:00f0221154Решил занятся питоном, пишу простенький енкодер.<br/>Имею такой код:<br/><div class="code"><pre>import sha<br/>import md5<br/>import sys<br/>import base64<br/>while 1:<br/> ptext=raw_input("\nline: ")<br/> s=sha.new(ptext)<br/> m=md5.new(ptext)<br/> b=base64.b64encode(ptext)<br/> h=hex(ptext)<br/> print "SHA-1: "+s.hexdigest()<br/> print "MD5: "+m.hexdigest()<br/> print "Base64: "+b<br/> print "hex: " +h()</pre></div>При кодировании в hex, выдает ошибку=(. в чем проблема?<br/>пробовал отдельно хекс, в консоли, там ошибок нет, но кодируются только цифры. в чем трабл?<br/>Спасибо:)