'int' object has no attribute 'startswith'


I'm getting strange error "'int' object has no attribute 'startswith'"

I haven't used the word "startswith" in my python program. ? Does any one how to fix this -- or what it refers to ?


Something in your program is trying to call the startswith method of an object, probably because it expects it to be a string. You'll have to pay attention to the traceback to see what it is being called on, and why that is an integer instead of a string. Did you pass along an integer where a string was expected?


startswith only works with strings.

If you need to check if an int starts with a set of numbers, you can convert it to a string, i.e.:

someint = 1234 if str(someint).startswith("123"): # do somenting


  • PayPal REST API cross reference transaction with payment
  • undefined method `posts_path' for #
  • Braintree Dropin UI does not work with Ionic Framework unless force refresh
  • FParsec: how to combine parsers so that they will be matched in arbitrary order
  • FIR filter in CUDA (as a 1D convolution)
  • PhpStorm: annotation for inherited method return type?
  • Obtain actual browser URL in PHP
  • Unique SMS sender id?
  • How does inheritance and polymorphism work in this situation?
  • What does “t” refer to in this SQL?
  • Memory error in python- how to use more memory
  • Differences in dis-assembled C code of GCC and Borland?
  • Jackson Parser: ignore deserializing for type mismatch
  • Refering to the class itself from within a class mehod in Objective C
  • Algorithm for a smudge tool?
  • Bug in WPF DataGrid
  • TFS: Get latest causes slow project reloading
  • Javascript Callbacks with Object constructor
  • Trying to switch camera back to front but getting exception
  • How to make Safari send if-modified-since header?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Akka Routing: Reply's send to router ends up as dead letters
  • AT Commands to Send SMS not working in Windows 8.1
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • Free memory of cv::Mat loaded using FileStorage API
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • Angular 2 constructor injection vs direct access
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • How do I configure my settings file to work with unit tests?
  • Change div Background jquery
  • How does Linux kernel interrupt the application?
  • apache spark aggregate function using min value
  • Is it possible to post an object from jquery to bottle.py?
  • Checking variable from a different class in C#
  • Programmatically clearing map cache
  • Busy indicator not showing up in wpf window [duplicate]
  • Sorting a 2D array using the second column C++
  • Why do underscore prefixed variables exist?
  • java string with new operator and a literal