How about this?
>>> s="23.45678"
>>> int(float(s))
23
Or…
>>> int(Decimal(s))
23
Or…
>>> int(s.split('.')[0])
23
I doubt it’s going to get much simpler than that, I’m afraid. Just accept it and move on.
More Related Contents:
- How to convert strings into integers?
- Is there a way to convert number words to Integers?
- Python: TypeError: cannot concatenate ‘str’ and ‘int’ objects [duplicate]
- Converting integer to string in Python
- Python strings and integer concatenation [duplicate]
- How to split a string of space separated numbers into integers?
- How can I check if a string represents an int, without using try/except?
- How to get integer values from a string in Python?
- inheritance from str or int
- Easy way of finding decimal places
- formatting long numbers as strings in python
- Split an integer into digits to compute an ISBN checksum
- How do I convert all strings in a list of lists to integers?
- Convert integer to string in Python
- TypeError: cannot concatenate ‘str’ and ‘int’ objects [duplicate]
- How to convert a string of space- and comma- separated numbers into a list of int? [duplicate]
- Splitting List That Contains Strings and Integers
- How do I check if raw input is integer in python 2.7?
- Formatting long numbers as strings
- How can I convert string values from a dictionary, into int/float datatypes?
- How can I check if a string has a numeric value in it in Python? [duplicate]
- Python String concatenation with in double quotes [closed]
- How to extract numbers from a string in Python?
- How can I fill out a Python string with spaces?
- What does preceding a string literal with “r” mean? [duplicate]
- What’s the difference between str.isdigit, isnumeric and isdecimal in python?
- Time complexity of string concatenation in Python [duplicate]
- How to make a string’s content appears on screen as we type on keyboard? [duplicate]
- ValueError: invalid literal for int() with base 10: ‘stop’
- Reverse a string without using reversed() or [::-1]?