Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
プログラミング初心者はこちら (パイソン2.7)
Python の ord 関数に複数の文字を使用するための回避策はありますか?
たとえば、16 進文字列 '\xff\x1a' があり、他の 16 進文字列と合計できるように 10 進値が必要です。ただし、ord は単一の 16 進文字列のみを受け入れます。
ありがとうございました!
文字列は反復可能であるため、文字列をループしてord、結果を使用および追加できます。
ord
your_sum = sum([ord(i) for i in '\xff\x1a'])