问:
How to create an img from an existing svg
Let suppose I have an svg inside my page just like:

```<svg style="width: 100%; height: 100%; overflow: hidden; left: 0px; top: -0.666667px;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"><defs><clipPath id="kdef3"><path d="M57 58.5 L 591 58.5 591 349 57 349Z" stroke="#000" stroke-linejoin="miter" fill="none"></path></clipPath><clipPath id="kdef4"><path d="M5 5 L 592 5 592 395 5 395Z" stroke="#000" stroke-linejoin="miter" fill="none"></path></clipPath></defs><g><path d="M0 0 L 597 0 597 400 0 400Z" stroke="none" fill="#fff"></path><path d="M57 58.5 L 591 58.5 591 349 57 349Z" stroke="none" fill="#fff" fill-opacity="0"></path><g><g></g><g><path d="M57.5 317.5 L 591.5 317.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 284.5 L 591.5 284.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 252.5 L 591.5 252.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 220.5 L 591.5 220.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 188.5 L 591.5 188.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 155.5 L 591.5 155.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 123.5 L 591.5 123.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 91.5 L 591.5 91.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 59.5 L 591.5 59.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path></g><g><g><g><path d="M57.5 349.5 L 591.5 349.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M57.5 349.5 L 57.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M75.5 349.5 L 75.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M93.5 349.5 L 93.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M110.5 349.5 L 110.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M128.5 349.5 L 128.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M146.5 349.5 L 146.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M164.5 349.5 L 164.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M182.5 349.5 L 182.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M199.5 349.5 L 199.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M217.5 349.5 L 217.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M235.5 349.5 L 235.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M253.5 349.5 L 253.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M271.5 349.5 L 271.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M288.5 349.5 L 288.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M306.5 349.5 L 306.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M324.5 349.5 L 324.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M342.5 349.5 L 342.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M360.5 349.5 L 360.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M377.5 349.5 L 377.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M395.5 349.5 L 395.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M413.5 349.5 L 413.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M431.5 349.5 L 431.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M449.5 349.5 L 449.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M466.5 349.5 L 466.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M484.5 349.5 L 484.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M502.5 349.5 L 502.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M520.5 349.5 L 520.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M538.5 349.5 L 538.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M555.5 349.5 L 555.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M573.5 349.5 L 573.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M591.5 349.5 L 591.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path></g></g></g><g clip-path="url(#kdef3)"><g clip-path="url(#kdef4)"><path d="M65.9 334.798 C 71.827 329.853 77.773 324.034 83.7 319.95 89.627 315.866 95.573 313.599 101.5 310.267 107.427 306.935 113.373 303.055 119.3 299.938 125.227 296.821 131.173 294.018 137.1 291.546 143.027 289.073 148.973 287.455 154.9 285.09 160.827 282.725 166.773 279.708 172.7 277.343 178.627 274.979 184.573 273.037 190.5 270.888 196.427 268.738 202.373 266.797 208.3 264.432 214.227 262.068 220.173 260.34 226.1 256.686 232.027 253.031 237.973 246.353 243.9 242.483 249.827 238.614 255.773 236.778 261.7 233.446 267.627 230.114 273.573 225.481 279.5 222.471 285.427 219.462 291.373 218.487 297.3 215.37 303.227 212.253 309.173 206.76 315.1 203.75 321.027 200.74 326.973 199.767 332.9 197.294 338.827 194.822 344.773 192.664 350.7 188.902 356.627 185.14 362.573 177.925 368.5 174.7 374.427 171.475 380.373 172.223 386.3 169.536 392.227 166.848 398.173 161.463 404.1 158.561 410.027 155.659 415.973 154.47 421.9 152.106 427.827 149.741 433.773 147.153 439.7 144.359 445.627 141.564 451.573 137.686 457.5 135.321 463.427 132.956 469.373 132.091 475.3 130.157 481.227 128.222 487.173 125.958 493.1 123.701 499.027 121.444 504.973 119.287 510.9 116.6 516.827 113.913 522.773 110.679 528.7 107.562 534.627 104.445 540.573 101.426 546.5 97.879 552.427 94.332 558.373 89.698 564.3 86.259 570.227 82.819 576.173 80.231 582.1 77.221" stroke="#ff6800" stroke-width="2" fill="none"></path><path d="M65.9 341.899 C 71.827 337.814 77.773 333.61 83.7 329.633 89.627 325.656 95.573 321.13 101.5 318.013 107.427 314.896 113.373 313.814 119.3 310.912 125.227 308.01 131.173 303.915 137.1 300.583 143.027 297.251 148.973 294.34 154.9 290.9 160.827 287.46 166.773 283.365 172.7 279.926 178.627 276.486 184.573 274.327 190.5 270.242 196.427 266.158 202.373 258.619 208.3 255.394 214.227 252.17 220.173 252.595 226.1 250.876 232.027 249.156 237.973 247.43 243.9 245.066 249.827 242.701 255.773 239.575 261.7 236.673 267.627 233.771 273.573 230.538 279.5 227.636 285.427 224.733 291.373 221.93 297.3 219.243 303.227 216.556 309.173 214.076 315.1 211.497 321.027 208.917 326.973 206.007 332.9 203.75 338.827 201.493 344.773 200.197 350.7 197.94 356.627 195.683 362.573 192.558 368.5 190.193 374.427 187.829 380.373 186.317 386.3 183.738 392.227 181.158 398.173 177.28 404.1 174.7 410.027 172.12 415.973 170.394 421.9 168.244 427.827 166.095 433.773 164.046 439.7 161.789 445.627 159.532 451.573 157.16 457.5 154.688 463.427 152.216 469.373 149.736 475.3 146.941 481.227 144.147 487.173 140.913 493.1 137.903 499.027 134.894 504.973 132.52 510.9 128.866 516.827 125.211 522.773 120.039 528.7 115.954 534.627 111.87 540.573 107.989 546.5 104.334 552.427 100.68 558.373 94.006 564.3 94.006 570.227 94.006 576.173 94.006 582.1 94.006" stroke="#a0a700" stroke-width="2" fill="none"></path><circle cx="65.9" cy="334.798" r="4.0000000000000036" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="65.9" cy="341.899" r="4.0000000000000036" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="83.7" cy="319.95" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="83.7" cy="329.633" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="101.5" cy="310.267" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="101.5" cy="318.013" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="119.3" cy="299.938" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="119.3" cy="310.912" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="137.1" cy="291.546" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="137.1" cy="300.583" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="154.9" cy="285.09" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="154.9" cy="290.9" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="172.7" cy="277.343" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="172.7" cy="279.926" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="190.5" cy="270.888" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="190.5" cy="270.242" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="208.3" cy="264.432" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="208.3" cy="255.394" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="226.1" cy="256.686" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="226.1" cy="250.876" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="243.9" cy="242.483" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="243.9" cy="245.066" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="261.7" cy="233.446" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="261.7" cy="236.673" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="279.5" cy="222.471" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="279.5" cy="227.636" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="297.3" cy="215.37" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="297.3" cy="219.243" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="315.1" cy="203.75" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="315.1" cy="211.497" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="332.9" cy="197.294" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="332.9" cy="203.75" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="350.7" cy="188.902" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="350.7" cy="197.94" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="368.5" cy="174.7" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="368.5" cy="190.193" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="386.3" cy="169.536" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="386.3" cy="183.738" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="404.1" cy="158.561" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="404.1" cy="174.7" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="421.9" cy="152.106" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="421.9" cy="168.244" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="439.7" cy="144.359" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="439.7" cy="161.789" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="457.5" cy="135.321" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="457.5" cy="154.688" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="475.3" cy="130.157" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="475.3" cy="146.941" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="493.1" cy="123.701" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="493.1" cy="137.903" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="510.9" cy="116.6" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="510.9" cy="128.866" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="528.7" cy="107.562" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="528.7" cy="115.954" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="546.5" cy="97.879" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="546.5" cy="104.334" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="564.3" cy="86.259" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="564.3" cy="94.006" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="582.1" cy="77.221" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="582.1" cy="94.006" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle></g></g><g><text style="font:14px Arial,Helvetica,sans-serif;" x="271.5" y="399" stroke="none" fill="#000001" fill-opacity="1">DAY OF MONTH</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="62.89999999999999" y="368" stroke="none" fill="#000001" fill-opacity="1">1</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="80.69999999999999" y="380" stroke="none" fill="#000001" fill-opacity="1">2</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="98.5" y="368" stroke="none" fill="#000001" fill-opacity="1">3</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="116.3" y="380" stroke="none" fill="#000001" fill-opacity="1">4</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="134.1" y="368" stroke="none" fill="#000001" fill-opacity="1">5</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="151.9" y="380" stroke="none" fill="#000001" fill-opacity="1">6</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="169.7" y="368" stroke="none" fill="#000001" fill-opacity="1">7</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="187.5" y="380" stroke="none" fill="#000001" fill-opacity="1">8</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="205.3" y="368" stroke="none" fill="#000001" fill-opacity="1">9</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="220.6" y="380" stroke="none" fill="#000001" fill-opacity="1">10</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="238.9" y="368" stroke="none" fill="#000001" fill-opacity="1">11</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="256.20000000000005" y="380" stroke="none" fill="#000001" fill-opacity="1">12</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="274" y="368" stroke="none" fill="#000001" fill-opacity="1">13</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="291.79999999999995" y="380" stroke="none" fill="#000001" fill-opacity="1">14</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="309.6" y="368" stroke="none" fill="#000001" fill-opacity="1">15</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="327.4" y="380" stroke="none" fill="#000001" fill-opacity="1">16</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="345.20000000000005" y="368" stroke="none" fill="#000001" fill-opacity="1">17</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="363" y="380" stroke="none" fill="#000001" fill-opacity="1">18</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="380.79999999999995" y="368" stroke="none" fill="#000001" fill-opacity="1">19</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="398.6" y="380" stroke="none" fill="#000001" fill-opacity="1">20</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="416.4" y="368" stroke="none" fill="#000001" fill-opacity="1">21</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="434.20000000000005" y="380" stroke="none" fill="#000001" fill-opacity="1">22</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="452" y="368" stroke="none" fill="#000001" fill-opacity="1">23</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="469.79999999999995" y="380" stroke="none" fill="#000001" fill-opacity="1">24</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="487.6" y="368" stroke="none" fill="#000001" fill-opacity="1">25</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="505.4" y="380" stroke="none" fill="#000001" fill-opacity="1">26</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="523.2" y="368" stroke="none" fill="#000001" fill-opacity="1">27</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="541" y="380" stroke="none" fill="#000001" fill-opacity="1">28</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="558.8" y="368" stroke="none" fill="#000001" fill-opacity="1">29</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="576.6" y="380" stroke="none" fill="#000001" fill-opacity="1">30</text></g><g><g><path d="M57.5 59.5 L 57.5 349.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 349.5 L 57.5 349.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 317.5 L 57.5 317.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 284.5 L 57.5 284.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 252.5 L 57.5 252.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 220.5 L 57.5 220.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 188.5 L 57.5 188.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 155.5 L 57.5 155.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 123.5 L 57.5 123.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 91.5 L 57.5 91.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 59.5 L 57.5 59.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path></g></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="42" y="353.5" stroke="none" fill="#232323" fill-opacity="1">0</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="37" y="321.222" stroke="none" fill="#232323" fill-opacity="1">50</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="288.944" stroke="none" fill="#232323" fill-opacity="1">100</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="256.667" stroke="none" fill="#232323" fill-opacity="1">150</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="224.389" stroke="none" fill="#232323" fill-opacity="1">200</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="192.111" stroke="none" fill="#232323" fill-opacity="1">250</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="159.833" stroke="none" fill="#232323" fill-opacity="1">300</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="127.55600000000001" stroke="none" fill="#232323" fill-opacity="1">350</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="95.278" stroke="none" fill="#232323" fill-opacity="1">400</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="63" stroke="none" fill="#232323" fill-opacity="1">450</text></g><g transform="matrix(0,-1,1,0,-191.25,263.75)"><text style="font:14px Arial,Helvetica,sans-serif;" x="10" y="209.25" stroke="none" fill="#232323" fill-opacity="1"># OF VESSELS</text></g></g><g><g><text style="font:24px Arial,Helvetica,sans-serif;" x="219.5" y="37" stroke="none" fill="#8e8e8e" fill-opacity="1">All Movements</text></g></g><g></g><g><g><g transform="matrix(1,0,0,1,507,10)"><path d="M1 3.5 L 8 3.5 8 10.5 1 10.5Z" stroke="#ff6800" stroke-width="1" fill="#ff6800"></path><g><text style="font:12px Arial,Helvetica,sans-serif;" x="15" y="11" stroke="none" fill="#232323" fill-opacity="1">This Month</text></g><path style="cursor:pointer;" d="M0 0 L 75 0 75 14 0 14Z" stroke="none" fill="#fff" fill-opacity="0"></path></g><g transform="matrix(1,0,0,1,507,24)"><path d="M1 3.5 L 8 3.5 8 10.5 1 10.5Z" stroke="#a0a700" stroke-width="1" fill="#a0a700"></path><g><text style="font:12px Arial,Helvetica,sans-serif;" x="15" y="11" stroke="none" fill="#232323" fill-opacity="1">Last Month</text></g><path style="cursor:pointer;" d="M0 0 L 75 0 75 14 0 14Z" stroke="none" fill="#fff" fill-opacity="0"></path></g></g></g><g></g></g></svg>
```

<p>I want to create an img from this svg. I have been testing this function:</p>

```function beforePDFPrinting() {
    var cc = $('svg');
        for (i = 0; i < cc.length; i++) {
            var svg = cc[i];

            var img = new Image();
            img.crossOrigin = "Anonymous";
            img.src = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svg.outerHTML)));
            img.style = "width:'100%';height:'100%';";
            img.className = "remove-after-print";
            svg.parentNode.insertBefore(img, svg);

            svg.parentNode.removeChild(svg);
        }
    }
```

...but it does not work on IE.
Can you please show me what should I do in order to make it works on IE too. Thanks in advance.

答:
You can do this if you use canvg js; first export your svg to a canvas and then get the img from the canvas.

You need to include these links:

```<code><script type="text/javascript" src="http://canvg.github.io/canvg/rgbcolor.js"></script>
<script type="text/javascript" src="http://canvg.github.io/canvg/StackBlur.js"></script>
<script type="text/javascript" src="http://canvg.github.io/canvg/canvg.js"></script>
</code>```

Then your function is going to be something like:

```<code> function beforePDFPrinting() {
        var cc = $('svg');
        for (var index = 0; index < cc.length; index++) {
            var svg = cc[index];
            svg.setAttribute("width", svg.parentNode.clientWidth);
            svg.setAttribute("height", svg.parentNode.clientHeight);

            var svgText = svg.parentNode.innerHTML.replace(/\r?\n|\r/g, '').trim();

            //get the canvas
            $('body').append('<canvas width="' + svg.parentNode.clientWidth + '" height="' + svg.parentNode.clientHeight + '" id="thecanvas' + index + '"></canvas>')
            var canvas = document.getElementById("thecanvas" + index);

            canvg(canvas, svgText,
                {
                    ignoreDimensions: true,
                    scaleWidth: svg.parentNode.clientWidth,
                    scaleHeight: svg.parentNode.clientHeight,
                })

            var img = new Image();
            img.src = canvas.toDataURL();
            img.className = "remove-after-print";
            svg.parentNode.insertBefore(img, svg);

            canvas.parentNode.removeChild(canvas);
            svg.parentNode.removeChild(svg);
        }
    }
</code>```

also you could add some styles (in this case I had to):

```<code><style>
    .remove-after-print {
        width: 100%;
        height: 100%;
    }
</style>
</code>```

Body:
Let suppose I have an svg inside my page just like:

<svg style="width: 100%; height: 100%; overflow: hidden; left: 0px; top: -0.666667px;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1"><defs><clipPath id="kdef3"><path d="M57 58.5 L 591 58.5 591 349 57 349Z" stroke="#000" stroke-linejoin="miter" fill="none"></path></clipPath><clipPath id="kdef4"><path d="M5 5 L 592 5 592 395 5 395Z" stroke="#000" stroke-linejoin="miter" fill="none"></path></clipPath></defs><g><path d="M0 0 L 597 0 597 400 0 400Z" stroke="none" fill="#fff"></path><path d="M57 58.5 L 591 58.5 591 349 57 349Z" stroke="none" fill="#fff" fill-opacity="0"></path><g><g></g><g><path d="M57.5 317.5 L 591.5 317.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 284.5 L 591.5 284.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 252.5 L 591.5 252.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 220.5 L 591.5 220.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 188.5 L 591.5 188.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 155.5 L 591.5 155.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 123.5 L 591.5 123.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 91.5 L 591.5 91.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path><path d="M57.5 59.5 L 591.5 59.5" stroke="#dfdfdf" stroke-width="1" fill="none"></path></g><g><g><g><path d="M57.5 349.5 L 591.5 349.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M57.5 349.5 L 57.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M75.5 349.5 L 75.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M93.5 349.5 L 93.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M110.5 349.5 L 110.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M128.5 349.5 L 128.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M146.5 349.5 L 146.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M164.5 349.5 L 164.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M182.5 349.5 L 182.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M199.5 349.5 L 199.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M217.5 349.5 L 217.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M235.5 349.5 L 235.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M253.5 349.5 L 253.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M271.5 349.5 L 271.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M288.5 349.5 L 288.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M306.5 349.5 L 306.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M324.5 349.5 L 324.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M342.5 349.5 L 342.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M360.5 349.5 L 360.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M377.5 349.5 L 377.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M395.5 349.5 L 395.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M413.5 349.5 L 413.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M431.5 349.5 L 431.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M449.5 349.5 L 449.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M466.5 349.5 L 466.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M484.5 349.5 L 484.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M502.5 349.5 L 502.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M520.5 349.5 L 520.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M538.5 349.5 L 538.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M555.5 349.5 L 555.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M573.5 349.5 L 573.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path><path d="M591.5 349.5 L 591.5 353.5" stroke="#000001" stroke-width="1" fill="none"></path></g></g></g><g clip-path="url(#kdef3)"><g clip-path="url(#kdef4)"><path d="M65.9 334.798 C 71.827 329.853 77.773 324.034 83.7 319.95 89.627 315.866 95.573 313.599 101.5 310.267 107.427 306.935 113.373 303.055 119.3 299.938 125.227 296.821 131.173 294.018 137.1 291.546 143.027 289.073 148.973 287.455 154.9 285.09 160.827 282.725 166.773 279.708 172.7 277.343 178.627 274.979 184.573 273.037 190.5 270.888 196.427 268.738 202.373 266.797 208.3 264.432 214.227 262.068 220.173 260.34 226.1 256.686 232.027 253.031 237.973 246.353 243.9 242.483 249.827 238.614 255.773 236.778 261.7 233.446 267.627 230.114 273.573 225.481 279.5 222.471 285.427 219.462 291.373 218.487 297.3 215.37 303.227 212.253 309.173 206.76 315.1 203.75 321.027 200.74 326.973 199.767 332.9 197.294 338.827 194.822 344.773 192.664 350.7 188.902 356.627 185.14 362.573 177.925 368.5 174.7 374.427 171.475 380.373 172.223 386.3 169.536 392.227 166.848 398.173 161.463 404.1 158.561 410.027 155.659 415.973 154.47 421.9 152.106 427.827 149.741 433.773 147.153 439.7 144.359 445.627 141.564 451.573 137.686 457.5 135.321 463.427 132.956 469.373 132.091 475.3 130.157 481.227 128.222 487.173 125.958 493.1 123.701 499.027 121.444 504.973 119.287 510.9 116.6 516.827 113.913 522.773 110.679 528.7 107.562 534.627 104.445 540.573 101.426 546.5 97.879 552.427 94.332 558.373 89.698 564.3 86.259 570.227 82.819 576.173 80.231 582.1 77.221" stroke="#ff6800" stroke-width="2" fill="none"></path><path d="M65.9 341.899 C 71.827 337.814 77.773 333.61 83.7 329.633 89.627 325.656 95.573 321.13 101.5 318.013 107.427 314.896 113.373 313.814 119.3 310.912 125.227 308.01 131.173 303.915 137.1 300.583 143.027 297.251 148.973 294.34 154.9 290.9 160.827 287.46 166.773 283.365 172.7 279.926 178.627 276.486 184.573 274.327 190.5 270.242 196.427 266.158 202.373 258.619 208.3 255.394 214.227 252.17 220.173 252.595 226.1 250.876 232.027 249.156 237.973 247.43 243.9 245.066 249.827 242.701 255.773 239.575 261.7 236.673 267.627 233.771 273.573 230.538 279.5 227.636 285.427 224.733 291.373 221.93 297.3 219.243 303.227 216.556 309.173 214.076 315.1 211.497 321.027 208.917 326.973 206.007 332.9 203.75 338.827 201.493 344.773 200.197 350.7 197.94 356.627 195.683 362.573 192.558 368.5 190.193 374.427 187.829 380.373 186.317 386.3 183.738 392.227 181.158 398.173 177.28 404.1 174.7 410.027 172.12 415.973 170.394 421.9 168.244 427.827 166.095 433.773 164.046 439.7 161.789 445.627 159.532 451.573 157.16 457.5 154.688 463.427 152.216 469.373 149.736 475.3 146.941 481.227 144.147 487.173 140.913 493.1 137.903 499.027 134.894 504.973 132.52 510.9 128.866 516.827 125.211 522.773 120.039 528.7 115.954 534.627 111.87 540.573 107.989 546.5 104.334 552.427 100.68 558.373 94.006 564.3 94.006 570.227 94.006 576.173 94.006 582.1 94.006" stroke="#a0a700" stroke-width="2" fill="none"></path><circle cx="65.9" cy="334.798" r="4.0000000000000036" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="65.9" cy="341.899" r="4.0000000000000036" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="83.7" cy="319.95" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="83.7" cy="329.633" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="101.5" cy="310.267" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="101.5" cy="318.013" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="119.3" cy="299.938" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="119.3" cy="310.912" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="137.1" cy="291.546" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="137.1" cy="300.583" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="154.9" cy="285.09" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="154.9" cy="290.9" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="172.7" cy="277.343" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="172.7" cy="279.926" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="190.5" cy="270.888" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="190.5" cy="270.242" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="208.3" cy="264.432" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="208.3" cy="255.394" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="226.1" cy="256.686" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="226.1" cy="250.876" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="243.9" cy="242.483" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="243.9" cy="245.066" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="261.7" cy="233.446" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="261.7" cy="236.673" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="279.5" cy="222.471" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="279.5" cy="227.636" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="297.3" cy="215.37" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="297.3" cy="219.243" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="315.1" cy="203.75" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="315.1" cy="211.497" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="332.9" cy="197.294" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="332.9" cy="203.75" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="350.7" cy="188.902" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="350.7" cy="197.94" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="368.5" cy="174.7" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="368.5" cy="190.193" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="386.3" cy="169.536" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="386.3" cy="183.738" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="404.1" cy="158.561" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="404.1" cy="174.7" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="421.9" cy="152.106" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="421.9" cy="168.244" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="439.7" cy="144.359" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="439.7" cy="161.789" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="457.5" cy="135.321" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="457.5" cy="154.688" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="475.3" cy="130.157" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="475.3" cy="146.941" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="493.1" cy="123.701" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="493.1" cy="137.903" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="510.9" cy="116.6" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="510.9" cy="128.866" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="528.7" cy="107.562" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="528.7" cy="115.954" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="546.5" cy="97.879" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="546.5" cy="104.334" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="564.3" cy="86.259" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="564.3" cy="94.006" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="582.1" cy="77.221" r="4" stroke="#ff6800" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle><circle cx="582.1" cy="94.006" r="4" stroke="#a0a700" stroke-width="2" stroke-opacity="1" fill="#fff" fill-opacity="1"></circle></g></g><g><text style="font:14px Arial,Helvetica,sans-serif;" x="271.5" y="399" stroke="none" fill="#000001" fill-opacity="1">DAY OF MONTH</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="62.89999999999999" y="368" stroke="none" fill="#000001" fill-opacity="1">1</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="80.69999999999999" y="380" stroke="none" fill="#000001" fill-opacity="1">2</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="98.5" y="368" stroke="none" fill="#000001" fill-opacity="1">3</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="116.3" y="380" stroke="none" fill="#000001" fill-opacity="1">4</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="134.1" y="368" stroke="none" fill="#000001" fill-opacity="1">5</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="151.9" y="380" stroke="none" fill="#000001" fill-opacity="1">6</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="169.7" y="368" stroke="none" fill="#000001" fill-opacity="1">7</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="187.5" y="380" stroke="none" fill="#000001" fill-opacity="1">8</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="205.3" y="368" stroke="none" fill="#000001" fill-opacity="1">9</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="220.6" y="380" stroke="none" fill="#000001" fill-opacity="1">10</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="238.9" y="368" stroke="none" fill="#000001" fill-opacity="1">11</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="256.20000000000005" y="380" stroke="none" fill="#000001" fill-opacity="1">12</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="274" y="368" stroke="none" fill="#000001" fill-opacity="1">13</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="291.79999999999995" y="380" stroke="none" fill="#000001" fill-opacity="1">14</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="309.6" y="368" stroke="none" fill="#000001" fill-opacity="1">15</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="327.4" y="380" stroke="none" fill="#000001" fill-opacity="1">16</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="345.20000000000005" y="368" stroke="none" fill="#000001" fill-opacity="1">17</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="363" y="380" stroke="none" fill="#000001" fill-opacity="1">18</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="380.79999999999995" y="368" stroke="none" fill="#000001" fill-opacity="1">19</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="398.6" y="380" stroke="none" fill="#000001" fill-opacity="1">20</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="416.4" y="368" stroke="none" fill="#000001" fill-opacity="1">21</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="434.20000000000005" y="380" stroke="none" fill="#000001" fill-opacity="1">22</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="452" y="368" stroke="none" fill="#000001" fill-opacity="1">23</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="469.79999999999995" y="380" stroke="none" fill="#000001" fill-opacity="1">24</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="487.6" y="368" stroke="none" fill="#000001" fill-opacity="1">25</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="505.4" y="380" stroke="none" fill="#000001" fill-opacity="1">26</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="523.2" y="368" stroke="none" fill="#000001" fill-opacity="1">27</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="541" y="380" stroke="none" fill="#000001" fill-opacity="1">28</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="558.8" y="368" stroke="none" fill="#000001" fill-opacity="1">29</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="576.6" y="380" stroke="none" fill="#000001" fill-opacity="1">30</text></g><g><g><path d="M57.5 59.5 L 57.5 349.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 349.5 L 57.5 349.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 317.5 L 57.5 317.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 284.5 L 57.5 284.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 252.5 L 57.5 252.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 220.5 L 57.5 220.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 188.5 L 57.5 188.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 155.5 L 57.5 155.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 123.5 L 57.5 123.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 91.5 L 57.5 91.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path><path d="M53.5 59.5 L 57.5 59.5" stroke="#8e8e8e" stroke-width="1" fill="none"></path></g></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="42" y="353.5" stroke="none" fill="#232323" fill-opacity="1">0</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="37" y="321.222" stroke="none" fill="#232323" fill-opacity="1">50</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="288.944" stroke="none" fill="#232323" fill-opacity="1">100</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="256.667" stroke="none" fill="#232323" fill-opacity="1">150</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="224.389" stroke="none" fill="#232323" fill-opacity="1">200</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="192.111" stroke="none" fill="#232323" fill-opacity="1">250</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="159.833" stroke="none" fill="#232323" fill-opacity="1">300</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="127.55600000000001" stroke="none" fill="#232323" fill-opacity="1">350</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="95.278" stroke="none" fill="#232323" fill-opacity="1">400</text></g><g><text style="font:10px Arial,Helvetica,sans-serif;" x="31" y="63" stroke="none" fill="#232323" fill-opacity="1">450</text></g><g transform="matrix(0,-1,1,0,-191.25,263.75)"><text style="font:14px Arial,Helvetica,sans-serif;" x="10" y="209.25" stroke="none" fill="#232323" fill-opacity="1"># OF VESSELS</text></g></g><g><g><text style="font:24px Arial,Helvetica,sans-serif;" x="219.5" y="37" stroke="none" fill="#8e8e8e" fill-opacity="1">All Movements</text></g></g><g></g><g><g><g transform="matrix(1,0,0,1,507,10)"><path d="M1 3.5 L 8 3.5 8 10.5 1 10.5Z" stroke="#ff6800" stroke-width="1" fill="#ff6800"></path><g><text style="font:12px Arial,Helvetica,sans-serif;" x="15" y="11" stroke="none" fill="#232323" fill-opacity="1">This Month</text></g><path style="cursor:pointer;" d="M0 0 L 75 0 75 14 0 14Z" stroke="none" fill="#fff" fill-opacity="0"></path></g><g transform="matrix(1,0,0,1,507,24)"><path d="M1 3.5 L 8 3.5 8 10.5 1 10.5Z" stroke="#a0a700" stroke-width="1" fill="#a0a700"></path><g><text style="font:12px Arial,Helvetica,sans-serif;" x="15" y="11" stroke="none" fill="#232323" fill-opacity="1">Last Month</text></g><path style="cursor:pointer;" d="M0 0 L 75 0 75 14 0 14Z" stroke="none" fill="#fff" fill-opacity="0"></path></g></g></g><g></g></g></svg>

I want to create an img from this svg. I have been testing this function:

function beforePDFPrinting() {
    var cc = $('svg');
        for (i = 0; i < cc.length; i++) {
            var svg = cc[i];

            var img = new Image();
            img.crossOrigin = "Anonymous";
            img.src = 'data:image/svg+xml;base64,' + btoa(unescape(encodeURIComponent(svg.outerHTML)));
            img.style = "width:'100%';height:'100%';";
            img.className = "remove-after-print";
            svg.parentNode.insertBefore(img, svg);

            svg.parentNode.removeChild(svg);
        }
    }

...but it does not work on IE.
Can you please show me what should I do in order to make it works on IE too. Thanks in advance.

Body:
You can do this if you use canvg js; first export your svg to a canvas and then get the img from the canvas.

You need to include these links:

<script type="text/javascript" src="http://canvg.github.io/canvg/rgbcolor.js"></script>
<script type="text/javascript" src="http://canvg.github.io/canvg/StackBlur.js"></script>
<script type="text/javascript" src="http://canvg.github.io/canvg/canvg.js"></script>

Then your function is going to be something like:

 function beforePDFPrinting() {
        var cc = $('svg');
        for (var index = 0; index < cc.length; index++) {
            var svg = cc[index];
            svg.setAttribute("width", svg.parentNode.clientWidth);
            svg.setAttribute("height", svg.parentNode.clientHeight);

            var svgText = svg.parentNode.innerHTML.replace(/\r?\n|\r/g, '').trim();

            //get the canvas
            $('body').append('<canvas width="' + svg.parentNode.clientWidth + '" height="' + svg.parentNode.clientHeight + '" id="thecanvas' + index + '"></canvas>')
            var canvas = document.getElementById("thecanvas" + index);

            canvg(canvas, svgText,
                {
                    ignoreDimensions: true,
                    scaleWidth: svg.parentNode.clientWidth,
                    scaleHeight: svg.parentNode.clientHeight,
                })

            var img = new Image();
            img.src = canvas.toDataURL();
            img.className = "remove-after-print";
            svg.parentNode.insertBefore(img, svg);

            canvas.parentNode.removeChild(canvas);
            svg.parentNode.removeChild(svg);
        }
    }

also you could add some styles (in this case I had to):

<style>
    .remove-after-print {
        width: 100%;
        height: 100%;
    }
</style>


来源: stackexchange

问:
Defining global struct array of pointers
im learning c programing.
I want to define a global struct array of. so I would have a pointer to that array that each member of the array is a struct of complex numbers.
my goal is to be able to acces to this array by his pointer (*vars) and being able to change/read its members on every function at the main.

Im facing troubles with this issue and im not sure how and where to define each thing.
I tried this next code:

```<code>#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef struct complext
{
    double real;
    double img;
} complex;
complex* vars;

int main()
{
    int i;
    vars = malloc(6 * sizeof(vars));
    for (i = 0; i < 6;)
        vars[i]->real = 0;
}
</code>```

Im getting an error when im trying to acces vars[i].
"request for member 'real' im something not a structure or a union.
Thanks!

答:
There are 3 bugs in your code

1. vars[i]->real should be vars[i].real. Pls honor the data-types You have defined vars to be a global pointer to the complex structure. To define it as an array use: complex vars[6];  --> Look at @José Fonte 's ans

2. malloc returns a void * cast it to (complex*)  --> I learnt this should be ok (look at comments posted by @Stargateur)

3. The for loop at the end has no inc statement for i hence it runs forever

4. The malloc only allocates 6 pointer worth of memory (which is 6*sizeof(int)) since vars is a pointer of type complex.  sizeof(vars) should be sizeof(complex) --> @xing pointed this out

```<code>#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>

typedef struct complext {
double real;
double img;
}complex;
complex *vars;

int main()
{
int i;
vars= (complex*)malloc(6*sizeof(complex));
for(i=0;i<6; i++)
vars[i].real=0;
}
</code>```

ContentLicense: CC BY-SA 3.0

Body:
im learning c programing.
I want to define a global struct array of. so I would have a pointer to that array that each member of the array is a struct of complex numbers.
my goal is to be able to acces to this array by his pointer (*vars) and being able to change/read its members on every function at the main.

Im facing troubles with this issue and im not sure how and where to define each thing.
I tried this next code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef struct complext
{
    double real;
    double img;
} complex;
complex* vars;

int main()
{
    int i;
    vars = malloc(6 * sizeof(vars));
    for (i = 0; i < 6;)
        vars[i]->real = 0;
}

Im getting an error when im trying to acces vars[i].
"request for member 'real' im something not a structure or a union.
Thanks!

Body:
There are 3 bugs in your code

1. vars[i]->real should be vars[i].real. Pls honor the data-types You have defined vars to be a global pointer to the complex structure. To define it as an array use: complex vars[6];  --> Look at @José Fonte 's ans

2. malloc returns a void * cast it to (complex*)  --> I learnt this should be ok (look at comments posted by @Stargateur)

3. The for loop at the end has no inc statement for i hence it runs forever

4. The malloc only allocates 6 pointer worth of memory (which is 6*sizeof(int)) since vars is a pointer of type complex.  sizeof(vars) should be sizeof(complex) --> @xing pointed this out

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>

typedef struct complext {
double real;
double img;
}complex;
complex *vars;

int main()
{
int i;
vars= (complex*)malloc(6*sizeof(complex));
for(i=0;i<6; i++)
vars[i].real=0;
}


问:
How do you submit a form to an app engine python application without refreshing the sending page?
As a newbie to app engine and python I can follow the examples given by Google and have created a python application with a template HTML page where I can enter data, submit it to the datastore and by reading back the data, just sent, recreate the sending page so I can continue adding data and store again.  However what I would like to do is submit the data, have it stored in the datastore without the sending page being refreshed. It seems like a waste of traffic to have all the data sent back again.</p>

答: Sounds like you want to look into AJAX. The simplest way to do this is probably to use the ajax functions in one of the popular Javascript libraries, like jQuery.</p>

ContentLicense: CC BY-SA 2.5


问:
SharedPreferences Logout not working
I have 2 Activities, Authentication and Mainpage.

In Authentication, it checks if the user is logged in, if the user is logged in, redirect it to Mainpage.class. This is how Authentication checks if the user is logged in and redirect it.

```<code>SharedPreferences blockSession = this.getSharedPreferences("blockSession", 0);
boolean isLoggedIn = blockSession.getBoolean("logged_in", false);
if(isLoggedIn){
    Intent intent = new Intent(this, Mainpage.class);
    startActivity(intent);
}
</code>```

In Mainpage, I have a button which is a logout button and onClick event it use the logOut function that I've created. This is how logout button works:

```<code>void logOut(){
    SharedPreferences blockSession = this.getSharedPreferences("blockSession", 0);
    SharedPreferences.Editor blockEdit = blockSession.edit();
    blockEdit.clear();
    blockEdit.apply();
    finish();

    Intent intent = new Intent(Mainpage.this, Authentication.class);
    startActivity(intent);
}
</code>```

The problem here is when I click the logout button, I just kept redirecting to Mainpage.

答:
The problem is that you are finishing the activity before starting the Intent..That is why it shows MainPage when the logout() is called..Instead, you will have to finish the activity after the intent has been called.

Thus replace your code as follows

```<code>void logOut(){
    SharedPreferences blockSession = this.getSharedPreferences("blockSession", 0);
    SharedPreferences.Editor blockEdit = blockSession.edit();
    blockEdit.clear();
    blockEdit.apply();
    //finish();       /****<-----commented out this line---****/
    Intent intent = new Intent(Mainpage.this, Authentication.class);
    startActivity(intent);

    finish();        /****<------Moved to here---****/
}
</code>```

UPDATE

Since you are adding onClick attribute in your xml for the button and you are getting an error

java.lang.IllegalStateException: Could not find method logOut(View) in
  a parent or ancestor Context for android:onClick attribute defined on
  view class android.support.v7.widget.AppCompatButton with id
  'logoutButton'

Replace your function as follows

```<code>void logOut(View v){
    SharedPreferences blockSession = this.getSharedPreferences("blockSession", 0);
    SharedPreferences.Editor blockEdit = blockSession.edit();
    blockEdit.clear();
    blockEdit.apply();
    //finish();       /****<-----commented out this line---****/
    Intent intent = new Intent(Mainpage.this, Authentication.class);
    startActivity(intent);

    finish();        /****<------Moved to here---****/
}
</code>```

However, I dont think it's a good idea to solve this way. You should implement onClickListener inside your adapter or your fragment.

Title: SharedPreferences Logout not working

Body:
I have 2 Activities, Authentication and Mainpage.

In Authentication, it checks if the user is logged in, if the user is logged in, redirect it to Mainpage.class. This is how Authentication checks if the user is logged in and redirect it.

SharedPreferences blockSession = this.getSharedPreferences("blockSession", 0);
boolean isLoggedIn = blockSession.getBoolean("logged_in", false);
if(isLoggedIn){
    Intent intent = new Intent(this, Mainpage.class);
    startActivity(intent);
}

In Mainpage, I have a button which is a logout button and onClick event it use the logOut function that I've created. This is how logout button works:

void logOut(){
    SharedPreferences blockSession = this.getSharedPreferences("blockSession", 0);
    SharedPreferences.Editor blockEdit = blockSession.edit();
    blockEdit.clear();
    blockEdit.apply();
    finish();

    Intent intent = new Intent(Mainpage.this, Authentication.class);
    startActivity(intent);
}

The problem here is when I click the logout button, I just kept redirecting to Mainpage.

Body:
The problem is that you are finishing the activity before starting the Intent..That is why it shows MainPage when the logout() is called..Instead, you will have to finish the activity after the intent has been called.

Thus replace your code as follows

void logOut(){
    SharedPreferences blockSession = this.getSharedPreferences("blockSession", 0);
    SharedPreferences.Editor blockEdit = blockSession.edit();
    blockEdit.clear();
    blockEdit.apply();
    //finish();       /****<-----commented out this line---****/
    Intent intent = new Intent(Mainpage.this, Authentication.class);
    startActivity(intent);

    finish();        /****<------Moved to here---****/
}

UPDATE

Since you are adding onClick attribute in your xml for the button and you are getting an error

java.lang.IllegalStateException: Could not find method logOut(View) in
  a parent or ancestor Context for android:onClick attribute defined on
  view class android.support.v7.widget.AppCompatButton with id
  'logoutButton'

Replace your function as follows

void logOut(View v){
    SharedPreferences blockSession = this.getSharedPreferences("blockSession", 0);
    SharedPreferences.Editor blockEdit = blockSession.edit();
    blockEdit.clear();
    blockEdit.apply();
    //finish();       /****<-----commented out this line---****/
    Intent intent = new Intent(Mainpage.this, Authentication.class);
    startActivity(intent);

    finish();        /****<------Moved to here---****/
}

However, I dont think it's a good idea to solve this way. You should implement onClickListener inside your adapter or your fragment.


问:
A problem in Updation of the record c#
i don't know why every time i perform update of my record, the query from which i update do not increments the ID from 0 to 1 and always it takes 0.. i don't know how do i increment my id to 1 and so far.. please explain.. :/ .. my code is :</p>

```<code>private void btnUpdate_Click(object sender, EventArgs e)
            {
                int CustomerID =0;
                SqlConnection cn = new SqlConnection(@"Data Source=COMPAQ-PC-PC\SQLEXPRESS;
                Initial Catalog=Gym;Integrated Security=True");
                SqlCommand cmd  = new SqlCommand("Update Customer set Customer_Name = '" + tbName.Text + "',Cell_Number = '" + tbContactNumber.Text + "',Customer_Address = '" + tbAddress.Text + "' where CustomerID = " + CustomerID, cn);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);
                BindGridView();
            }

private void BindGridView()
        {
            SqlConnection cn = new SqlConnection(@"Data Source=COMPAQ-PC-PC\SQLEXPRESS;Initial Catalog=Gym;Integrated Security=True");
            SqlCommand cmd = new SqlCommand("Select * from Customer", cn);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            dgView_CustomerInfo.DataSource = dt.DefaultView;
        }
</code>```

答:
You are using "Update Customer" sql clause.
That means that you are going to update EXISTING record, not to insert NEW one.

The ID is incrementing only for NEW records, but not for existing ones.
Also, make sure that your ID column is properly configured.
It should has IDENTITY(1,1)clause like in example below:

```<code>CREATE TABLE [dbo].[td_Component](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Url] [nvarchar](250) NOT NULL,
    [Caption] [nvarchar](50) NOT NULL,
    [Description] [varchar](4000) NULL,
</code>```

Title: A problem in Updation of the record c#

Body:
i don't know why every time i perform update of my record, the query from which i update do not increments the ID from 0 to 1 and always it takes 0.. i don't know how do i increment my id to 1 and so far.. please explain.. :/ .. my code is :

private void btnUpdate_Click(object sender, EventArgs e)
            {
                int CustomerID =0;
                SqlConnection cn = new SqlConnection(@"Data Source=COMPAQ-PC-PC\SQLEXPRESS;
                Initial Catalog=Gym;Integrated Security=True");
                SqlCommand cmd  = new SqlCommand("Update Customer set Customer_Name = '" + tbName.Text + "',Cell_Number = '" + tbContactNumber.Text + "',Customer_Address = '" + tbAddress.Text + "' where CustomerID = " + CustomerID, cn);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = new DataTable();
                da.Fill(dt);
                BindGridView();
            }

private void BindGridView()
        {
            SqlConnection cn = new SqlConnection(@"Data Source=COMPAQ-PC-PC\SQLEXPRESS;Initial Catalog=Gym;Integrated Security=True");
            SqlCommand cmd = new SqlCommand("Select * from Customer", cn);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            dgView_CustomerInfo.DataSource = dt.DefaultView;
        }

Body:
You are using "Update Customer" sql clause.
That means that you are going to update EXISTING record, not to insert NEW one.

The ID is incrementing only for NEW records, but not for existing ones.
Also, make sure that your ID column is properly configured.
It should has IDENTITY(1,1)clause like in example below:

CREATE TABLE [dbo].[td_Component](
    [Id] [int] IDENTITY(1,1) NOT NULL,
    [Url] [nvarchar](250) NOT NULL,
    [Caption] [nvarchar](50) NOT NULL,
    [Description] [varchar](4000) NULL,


问:
How to convert a C++/CLI project from vcprj to vcxprj using Visual Studio 2017
I'm migrating a C++/CLI project from VS2008 to VS2017 but I always get an error when "reloading" the project to convert.

The project don't load and I don't see any clear error message about the reason.

答:
You should check that the correct components of Visual Studio 2017 are installed.

May be it's not installed by default in your case. It happened to me when I installed Visual Studio 2017 using this chocolatey package

You can solve this issue with the steps in this question: Visual Studio 2017 Professional C++/CLI Missing


问:
Django postgres remove all data created after a point in time
How can I remove all the objects which were created after some timestamp t in django?

Plainly, I need to remove all the objects (all rows in all tables) which have created_at > t. Is there any better solution than writing this:

```<code>models = [Model1, Model2, ..., ModelN]
for model in models:
   model.objects.filter(created_at__gt=t).delete()
</code>```

答:
One possibly improvement is to use get_models

```<code>from django.db import models
models_list = models.get_models()
</code>```

to automatically get the list of models, then delete them the way you do.

To only get the models for a specific application, you can do

```<code>from django.apps import apps
app = apps.get_config("app name")
models_list = app.models
</code>```

Body:
How can I remove all the objects which were created after some timestamp t in django?

Plainly, I need to remove all the objects (all rows in all tables) which have created_at > t. Is there any better solution than writing this:

models = [Model1, Model2, ..., ModelN]
for model in models:
   model.objects.filter(created_at__gt=t).delete()

Body:
One possibly improvement is to use get_models

from django.db import models
models_list = models.get_models()

to automatically get the list of models, then delete them the way you do.

To only get the models for a specific application, you can do

from django.apps import apps
app = apps.get_config("app name")
models_list = app.models


问:
Assigning elements to a list using for loop?
I have to figure out which is larger, the first or last element in a given list, and set all the other elements to be that value.

I wrote a code using a for loop, but I get an error that the list index is out of range.  What is my mistake?

The code is below:

```<code>def max_end3(nums):
    for i in nums:
        if (nums[0] > nums[len(nums)-1]):
            nums[i] = nums[0]
        else:
            nums[i] = nums[len(nums)-1]
        return (nums)
</code>```

答:
You do not have to do for loop since 'nums is already a list. I believe coding bat is giving array length is 3. So try this

```<code>def max_end3(nums):
  if nums[0] > nums[-1]:
    return nums[:1] *3
  elif nums[-1] > nums[0]:
    return nums[-1:] * 3
  elif nums[0] == nums[-1]:
    return nums[:1] * 3
  else:
    return nums
</code>```

Body:
I have to figure out which is larger, the first or last element in a given list, and set all the other elements to be that value.

I wrote a code using a for loop, but I get an error that the list index is out of range.  What is my mistake?

The code is below:

def max_end3(nums):
    for i in nums:
        if (nums[0] > nums[len(nums)-1]):
            nums[i] = nums[0]
        else:
            nums[i] = nums[len(nums)-1]
        return (nums)

Body:
You do not have to do for loop since 'nums is already a list. I believe coding bat is giving array length is 3. So try this

def max_end3(nums):
  if nums[0] > nums[-1]:
    return nums[:1] *3
  elif nums[-1] > nums[0]:
    return nums[-1:] * 3
  elif nums[0] == nums[-1]:
    return nums[:1] * 3
  else:
    return nums


答:
Here is an option:</p>

```<code>the_list = [6, 7, 2, 4, 5, 7]

val = max([the_list[0], the_list[-1])

the_list = [val]*len(the_list)
</code>```

Title: Assigning elements to a list using for loop?

Body:
Here is an option:

the_list = [6, 7, 2, 4, 5, 7]

val = max([the_list[0], the_list[-1])

the_list = [val]*len(the_list)


问:
Microsoft-Cognitive : Emotion API
I get the response below after making a call to the emotion api. How can i be able to have a variable that only gets the score for happiness only? I want something like data=happiness then i could be able to just print data.

```<code>{
    "FaceRectangle": {
      "Top": 141,
      "Left": 331,
      "Width": 52,
      "Height": 52
    },
    "Scores": {
      "Anger": 0.002451766,
      "Contempt": 0.0005512201,
      "Disgust": 0.0063303886,
      "Fear": 0.000122375583,
      "Happiness": 0.9589189,
      "Neutral": 0.0222537462,
      "Sadness": 0.008983561,
      "Surprise": 0.000388026354
    }
}
</code>```

Here is the python code

```<code>import http.client, urllib.request, urllib.parse, urllib.error, base64, sys

headers = {
    # Request headers. Replace the placeholder key below with your subscription key.
    'Content-Type': 'application/octet-stream',
    'Ocp-Apim-Subscription-Key': '**************************',
}

params = urllib.parse.urlencode({

        })

body = open('clouds.jpg','rb').read()

try:
    conn = http.client.HTTPSConnection('westus.api.cognitive.microsoft.com')
    conn.request("POST", "/emotion/v1.0/recognize?%s" % params, body, headers)

    response = conn.getresponse()
    data = response.read()
    print(data)

    conn.close()
</code>```

except Exception as e:
    print(e.args)

答:
@falsetru is correct, but you should note that Emotion API

Returns an array of faces, even if there's only one, and

The field names will be camel-cased, unlike the snippet you've added

import requests

body = {'url':'YOUR-IMAGE-URL'}
headers = {
  'Content-Type': 'application/json',
  'Ocp-Apim-Subscription-Key': 'YOUR-KEY'
}
req = requests.post('https://westus.api.cognitive.microsoft.com/emotion/v1.0/recognize', headers=headers, data=str(body))
faces = req.json()
for face in faces:
   print face['scores']['happiness']
```

Title: Microsoft-Cognitive : Emotion API

Body:
I get the response below after making a call to the emotion api. How can i be able to have a variable that only gets the score for happiness only? I want something like data=happiness then i could be able to just print data.

{
    "FaceRectangle": {
      "Top": 141,
      "Left": 331,
      "Width": 52,
      "Height": 52
    },
    "Scores": {
      "Anger": 0.002451766,
      "Contempt": 0.0005512201,
      "Disgust": 0.0063303886,
      "Fear": 0.000122375583,
      "Happiness": 0.9589189,
      "Neutral": 0.0222537462,
      "Sadness": 0.008983561,
      "Surprise": 0.000388026354
    }
}

Here is the python code

import http.client, urllib.request, urllib.parse, urllib.error, base64, sys

headers = {
    # Request headers. Replace the placeholder key below with your subscription key.
    'Content-Type': 'application/octet-stream',
    'Ocp-Apim-Subscription-Key': '**************************',
}

params = urllib.parse.urlencode({

        })

body = open('clouds.jpg','rb').read()

try:
    conn = http.client.HTTPSConnection('westus.api.cognitive.microsoft.com')
    conn.request("POST", "/emotion/v1.0/recognize?%s" % params, body, headers)

    response = conn.getresponse()
    data = response.read()
    print(data)

    conn.close()

except Exception as e:
    print(e.args)


问:
Error when trying to add counter_cache to a self-join rails model
```<code>class Product < ActiveRecord::Base
    belongs_to :parent, :class_name => 'Product', :foreign_key => :parent_id
    has_many :children, :class_name => 'Product', :foreign_key => :parent_id
</code>```

I am trying to add a counter cache to the :children column. I have tried the following:

```<code>belongs_to :parent, :class_name => 'Product', :foreign_key => :parent_id
has_many :children, :class_name => 'Product', :foreign_key => :parent_id, counter_cache: true
</code>```

and also:

```<code>has_many :children, :class_name => 'Product', :foreign_key => :parent_id, counter_cache: :children_count
</code>```

When I run Product.reset_counters(foo.id, :children)

I get the following error:

```<code>NoMethodError: undefined method `counter_cache_column' for nil:NilClass
</code>```

Am I not understanding something fundamental about counter_cache or self-joins? Information about this is scarce and doesn't apply to this type of self-join.

答:
the counter cash should be on the belongs to like

```<code>class Child  < ActiveRecord::Base
  belongs_to :product, counter_cache: true
...
</code>```

not on the has many in

```<code>class Product < ActiveRecord::Base
  belongs_to :parent, :class_name => 'Product', :foreign_key => :parent_id
  has_many :children, :class_name => 'Product', :foreign_key => :parent_id
</code>```

but the database column should still be on the product

read through 4.1.2.3 at this link for more info

Body:
class Product < ActiveRecord::Base
    belongs_to :parent, :class_name => 'Product', :foreign_key => :parent_id
    has_many :children, :class_name => 'Product', :foreign_key => :parent_id

I am trying to add a counter cache to the :children column. I have tried the following:

belongs_to :parent, :class_name => 'Product', :foreign_key => :parent_id
has_many :children, :class_name => 'Product', :foreign_key => :parent_id, counter_cache: true

and also:

has_many :children, :class_name => 'Product', :foreign_key => :parent_id, counter_cache: :children_count

When I run Product.reset_counters(foo.id, :children)

I get the following error:

NoMethodError: undefined method `counter_cache_column' for nil:NilClass

Am I not understanding something fundamental about counter_cache or self-joins? Information about this is scarce and doesn't apply to this type of self-join.

Body:
the counter cash should be on the belongs to like

class Child  < ActiveRecord::Base
  belongs_to :product, counter_cache: true
...

not on the has many in

class Product < ActiveRecord::Base
  belongs_to :parent, :class_name => 'Product', :foreign_key => :parent_id
  has_many :children, :class_name => 'Product', :foreign_key => :parent_id

but the database column should still be on the product

read through 4.1.2.3 at this link for more info


答:
It looks like for all communities you can use the crossing function to get which edges cross communities (see the docs for the communities object)

```<code>library(igraph)

out <- data.frame(To = sample(1:10, 20, replace = T), From =sample(c(1,3,5,7,9), 20, replace = T))

out <- graph_from_edgelist(as.matrix(out), directed = F)
co <- cluster_optimal(out, weights = rpois(20, 2))
coGrph <- delete_edges(out, E(out)[crossing(co, out)])

par(mfrow=c(1,2))
plot(co, out, main="Cluster Optimal Communities")
plot(coGrph, main="Communities split")
</code>```

Session Info

```<code>R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.12.5 (unknown)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] igraph_1.0.1

loaded via a namespace (and not attached):
[1] magrittr_1.5 tools_3.3.0
</code>```

Title: igraph split graph into clusters

Body:
I have some undirected graph:

with data:

get.data.frame(out)
   from   to  value sourceID targetID
1    74   80 0.2829   255609   262854
2    74   61 0.2880   255609   179585
3    80 1085 0.2997   262854  3055482
4  1045 1046 0.1842  2970629  2971615
5  1046 1085 0.2963  2971615  3055482
6  1046 1154 0.2714  2971615  3087803
7  1085 1154 0.2577  3055482  3087803
8  1085 1187 0.2850  3055482  3101131
9  1085 1209 0.2850  3055482  3110186
10 1154 1243 0.2577  3087803  3130848
11 1154 1187 0.2305  3087803  3101131
12 1154 1209 0.2305  3087803  3110186
13 1154 1244 0.2577  3087803  3131379
14 1243 1187 0.1488  3130848  3101131
15 1243 1209 0.1488  3130848  3110186
16 1243 1244 0.1215  3130848  3131379
17 1243 1281 0.2997  3130848  3255811

> out
IGRAPH UN-- 12 17 --
+ attr: name (v/c), color (v/n), value (e/n), sourceID (e/n), targetID (e/n)
+ edges (vertex names):
 [1] 74  --80   74  --61   80  --1085 1045--1046 1046--1085 1046--1154 1085--1154 1085--1187 1085--1209 1154--1243 1154--1187 1154--1209
[13] 1154--1244 1243--1187 1243--1209 1243--1244 1243--1281

I am using two methods for community detection.

Using edge.betweenness.community I can split communities by calculating edge betweenness:

wc <- edge.betweenness.community(out, weights = E(out)$value, directed = FALSE, bridges=TRUE)
plot(wc, out)

Using cluster_optimal I can split communities by maximising modularity:

co <- cluster_optimal(out, weights = E(out)$value)
plot(co, out)

Data for co:

> co
IGRAPH clustering optimal, groups: 3, mod: 0.27
+ groups:
  $`1`
  [1] "74" "80" "61"

  $`2`
  [1] "1045" "1046" "1085" "1154" "1187" "1209"

  $`3`
  [1] "1243" "1244" "1281"

At this point, I want to split these graphs into individual communities. This is done by cutting those edges that are highlighted red.

I can do this for edge.betweenness.community by returning those edges which are to be cut by doing:

wc$removed.edges
[1]  3  6  5 17 14 11  8 15  7 12  1  2  4  9 10 13 16

I can then cut those edges:

g2<-delete.edges(out, wc$removed.edges[seq(length=which.max(mods)-1)])
plot(g2)

But if I try this for cluster_optimal:

co$removed.edges
NULL

It looks like cluster_optimal has no attribute removed$edges

I then looked in the documentation (http://igraph.org/r/doc/communities.html) and tried cut_at and cutat:

> cutat(co, 3)
Error in cutat(co, 3) : Not a hierarchical communitity structure
> cut_at(co, 3)
Error in cut_at(co, 3) : Not a hierarchical communitity structure

This has not worked either, even though co should be a community object.

How can I split my cluster_optimal graph into the individual communities like I did with edge.betweenness.community?

Trying the suggestion posted, when i try to execute

crossing(co, out)

I get the error:

Error: Each element must be either an atomic vector or a data     frame
.Problems: co, out.

R version 3.4.0 (2017-04-21)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.5 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.0
LAPACK: /usr/lib/lapack/liblapack.so.3.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
 [1] plotly_4.7.0        ggplot2_2.2.1       tidyr_0.6.2         dtplyr_0.0.2        data.table_1.10.4   DT_0.2
 [7] reshape2_1.4.2      igraph_1.0.1        dplyr_0.5.0         htmlwidgets_0.8     networkD3_0.4       htmltools_0.3.6
[13] formattable_0.2.0.1

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.10      compiler_3.4.0    plyr_1.8.4        tools_3.4.0       digest_0.6.12     jsonlite_1.4      evaluate_0.10
 [8] tibble_1.3.0      gtable_0.2.0      viridisLite_0.2.0 lattice_0.20-35   Matrix_1.2-10     DBI_0.6-1         stringr_1.2.0
[15] httr_1.2.1        knitr_1.15.1      rprojroot_1.2     grid_3.4.0        R6_2.2.0          rmarkdown_1.5     purrr_0.2.2
[22] magrittr_1.5      backports_1.0.5   scales_0.4.1      assertthat_0.2.0  colorspace_1.3-2  stringi_1.1.5     lazyeval_0.2.0
[29] munsell_0.4.3

Body:
It looks like for all communities you can use the crossing function to get which edges cross communities (see the docs for the communities object)

library(igraph)

out <- data.frame(To = sample(1:10, 20, replace = T), From =sample(c(1,3,5,7,9), 20, replace = T))

out <- graph_from_edgelist(as.matrix(out), directed = F)
co <- cluster_optimal(out, weights = rpois(20, 2))
coGrph <- delete_edges(out, E(out)[crossing(co, out)])

par(mfrow=c(1,2))
plot(co, out, main="Cluster Optimal Communities")
plot(coGrph, main="Communities split")

Session Info

R version 3.3.0 (2016-05-03)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.12.5 (unknown)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] igraph_1.0.1

loaded via a namespace (and not attached):
[1] magrittr_1.5 tools_3.3.0


答:
for i in nums / nums[i] is not the proper way to index the list nums. I think you can try this instead:

```<code>def max_end3(nums):
    for i,num in enumerate(nums):
        if (nums[0] > nums[-1]):
            nums[i] = nums[0]
        else:
            nums[i] = nums[-1]
    return (nums)
</code>```

Use the built-in enumerate function to return "a tuple containing a count (from start which defaults to 0) and the values obtained from iterating over sequence." This allows you to concurrently index & iterate the values.

Use nums[-1] to represent the last item in the list, since Python supports negative indexing :)

Note: other solutions are more elegant, and this is not how I would solve the problem, but for a beginner it is sometimes easier to understand if working with simple constructs like for loop.

Body:
for i in nums / nums[i] is not the proper way to index the list nums. I think you can try this instead:

def max_end3(nums):
    for i,num in enumerate(nums):
        if (nums[0] > nums[-1]):
            nums[i] = nums[0]
        else:
            nums[i] = nums[-1]
    return (nums)

Use the built-in enumerate function to return "a tuple containing a count (from start which defaults to 0) and the values obtained from iterating over sequence." This allows you to concurrently index & iterate the values.

Use nums[-1] to represent the last item in the list, since Python supports negative indexing :)

Note: other solutions are more elegant, and this is not how I would solve the problem, but for a beginner it is sometimes easier to understand if working with simple constructs like for loop.


问:
Navigate from UIView to UIViewController without storyboard and navigation controller
Is there a way to navigate from a UIView, which is part of a UIViewController, to another UIViewController neither using storyboards nor navigation controllers?

I have a UITapGestureRecognizer which I want to navigate to another UIViewController (BuyController()) whenever it is tapped once.  Accordingly, my code looks like this:

```<code>//handle singleTap
func singleTapOnLikesDetected(_ sender: UITapGestureRecognizer) {

    print("check") //works
    let toController = BuyController()
    BarController().pushViewController(toController, animated: true) //error occurs since BarController is no navigationcontroller

}
</code>```

BarController (UITabBarController, UITabBarControllerDelegate) is my rootViewController in the AppDelegate.swift. The UIView however belongs to another UIViewController called HomeController (UIViewController, UIScrollViewDelegate). I do not use storyboards at all and I would like to keep it that way, as I am going to work on a project in a team (thus, a programmatic solution would be very welcome)...

答:
You can simply do this to navigate, without using navigationController:

```<code>self.present(toController, animated: true, completion: nil)
</code>```

Or Use this,

```<code>UIApplication.shared.keyWindow?.rootViewController?.present(toController, animated: true, completion: nil)
</code>```

Body:
Is there a way to navigate from a UIView, which is part of a UIViewController, to another UIViewController neither using storyboards nor navigation controllers?

I have a UITapGestureRecognizer which I want to navigate to another UIViewController (BuyController()) whenever it is tapped once.  Accordingly, my code looks like this:

//handle singleTap
func singleTapOnLikesDetected(_ sender: UITapGestureRecognizer) {

    print("check") //works
    let toController = BuyController()
    BarController().pushViewController(toController, animated: true) //error occurs since BarController is no navigationcontroller

}

BarController (UITabBarController, UITabBarControllerDelegate) is my rootViewController in the AppDelegate.swift. The UIView however belongs to another UIViewController called HomeController (UIViewController, UIScrollViewDelegate). I do not use storyboards at all and I would like to keep it that way, as I am going to work on a project in a team (thus, a programmatic solution would be very welcome)...

Body:
You can simply do this to navigate, without using navigationController:

self.present(toController, animated: true, completion: nil)

Or Use this,

UIApplication.shared.keyWindow?.rootViewController?.present(toController, animated: true, completion: nil)


问:
Unable to run import tensorflow as tf
I installed tensorflow using the following command.

```<code>pip install tensorflow
</code>```

I am running a simple program which is

```<code>import tensorflow as tf
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0) # also tf.float32 implicitly
print(node1, node2)
</code>```

I am getting the following error on running the program.

```<code>Traceback (most recent call last):
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\Python\lib\site-
packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "first.py", line 1, in <module>
import tensorflow as tf
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace above this error message when asking for help.
</code>```

I have updated the pip and am running the program on python 3.5

答:
This error message typically means that one of TensorFlow's dependencies cannot be found on your system. Since you are using the CPU-only version of TensorFlow on Windows, the most likely missing DLL is msvcp140.dll, which is required to run programs compiled using Microsoft Visual C++ 2015. This DLL is usually installed on developer machines as part of Visual Studio, or some Python distributions like Anaconda. However, the Python.org distribution of Python for Windows does not include it.

You can install msvcp140.dll on your system by downloading and installing the Microsoft Visual C++ 2015 Redistributable Update 3.

For others who find this answer, note that this script can help to diagnose common TensorFlow on Windows installation issues.

Title: Unable to run import tensorflow as tf

Body:
I installed tensorflow using the following command.

pip install tensorflow

I am running a simple program which is

import tensorflow as tf
node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0) # also tf.float32 implicitly
print(node1, node2)

I am getting the following error on running the program.

Traceback (most recent call last):
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\Python\lib\site-
packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "first.py", line 1, in <module>
import tensorflow as tf
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\__init__.py", line 24, in <module>
from tensorflow.python import *
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\__init__.py", line 51, in <module>
from tensorflow.python import pywrap_tensorflow
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
return importlib.import_module(mname)
File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap_external>", line 906, in create_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 21, in <module>
_pywrap_tensorflow_internal = swig_import_helper()
File "C:\Program Files (x86)\Python\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 20, in swig_import_helper
return importlib.import_module('_pywrap_tensorflow_internal')
File "C:\Program Files (x86)\Python\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ImportError: No module named '_pywrap_tensorflow_internal'

Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace above this error message when asking for help.

I have updated the pip and am running the program on python 3.5


答:
Your mixing pointers with arrays. Doing it as an array (as a pointer already done by @Zakir):</p>

```<code>#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>

typedef struct complext {
   double real;
   double img;
}complex;
complex vars[6];

int main()
{
   int i;

   for(i=0;i<6;i++)
   vars[i].real=0;
}
</code>```

Title: Defining global struct array of pointers

Body:
im learning c programing.
I want to define a global struct array of. so I would have a pointer to that array that each member of the array is a struct of complex numbers.
my goal is to be able to acces to this array by his pointer (*vars) and being able to change/read its members on every function at the main.

Im facing troubles with this issue and im not sure how and where to define each thing.
I tried this next code:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

typedef struct complext
{
    double real;
    double img;
} complex;
complex* vars;

int main()
{
    int i;
    vars = malloc(6 * sizeof(vars));
    for (i = 0; i < 6;)
        vars[i]->real = 0;
}

Im getting an error when im trying to acces vars[i].
"request for member 'real' im something not a structure or a union.
Thanks!

Body:
Your mixing pointers with arrays. Doing it as an array (as a pointer already done by @Zakir):

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>

typedef struct complext {
   double real;
   double img;
}complex;
complex vars[6];

int main()
{
   int i;

   for(i=0;i<6;i++)
   vars[i].real=0;
}


答:
You've confused an index with a list element.  Consider the input list [17, 3, -42, -3].  Your for statement steps i through the values 17, 3, -42, and -3, in that order.  However, the assignments you do assume that i is taking on the position or index values, 0, 1, 2, 3.

Try this, instead:

```<code>def max_end3(nums):
    for i in range(len(nums)):
        if (nums[0] > nums[len(nums)-1]):
            nums[i] = nums[0]
</code>```

Body:
You've confused an index with a list element.  Consider the input list [17, 3, -42, -3].  Your for statement steps i through the values 17, 3, -42, and -3, in that order.  However, the assignments you do assume that i is taking on the position or index values, 0, 1, 2, 3.

Try this, instead:

def max_end3(nums):
    for i in range(len(nums)):
        if (nums[0] > nums[len(nums)-1]):
            nums[i] = nums[0]