Every line of 'python bytes to string without b' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
11 def bytes_to_str(b): 12 if isinstance(b, bytes): 13 return str(b, 'utf8') 14 return b
25 def b(s): 26 return bytes(s, 'latin1')
43 def to_bytes(s): 44 if bytes != str: 45 if type(s) == str: 46 return s.encode('utf-8') 47 return s
40 def to_bytes(s): 41 if PY2: 42 if isinstance(s, unicode): 43 return s.encode('utf8') 44 return s 45 else: 46 if isinstance(s, str): 47 return s.encode('utf8') 48 return s
30 def bytes_to_str(s): 31 return s
106 def b(x): 107 """Convert to byte using encode(). 108 109 :param x: a unicode string 110 :return: a string 111 112 """ 113 s = str(x) 114 return s.encode(sg.__encoding__)
47 def b(data): 48 return bytes(data)
155 def _decode_str(b: bytes) -> str: 156 return _decode_dynamic_bytes(b).decode('utf8')
104 def strtobyte(s): 105 return bytes(s, encoding="ascii")
37 def to_bytes(str_or_bytes, encoding=ENCODING): 38 if isinstance(str_or_bytes, str): 39 return str_or_bytes.encode(encoding) 40 return str_or_bytes